package vfs.persist.association.impl;

import java.sql.Connection;
import vfs.filter.VFSFilter;
import vfs.obj.entity.VFSNode;
import vfs.persist.association.VFSNodeToParentManager;
import vfs.persist.entity.build.impl.VFSNodeBuilder;
import java.util.Iterator;

/**
 *
 * @author Matthew Eavenson <durandal@uga.edu>
 */
public class VFSNodeToParentManagerImpl implements VFSNodeToParentManager{
    
    private VFSAssociationManagerImpl<VFSNode, VFSNode> am;
    
    public VFSNodeToParentManagerImpl(Connection conn){
        VFSNodeBuilder builder = new VFSNodeBuilder();
        am = new VFSAssociationManagerImpl<VFSNode, VFSNode>(conn, builder, builder, "vfsNode", null, "parent");
    }
    
    @Override
    public Iterator<VFSNode> getChildren(VFSNode parent, VFSFilter filter){
        return am.findTM1(parent, filter);
    }
    
    @Override
    public VFSNode getParent(VFSNode node){
        return am.findUM1(node);
    }
    
    @Override
    public void setParent(VFSNode node, VFSNode parent){
        am.persistM1(node, parent);
    }
    
}
